/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package bpmlab.kivulifx.component;

import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.effect.DropShadow;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;

/**
 *
 * @author bpmlab
 */
public class Environment extends Pane {

    private final Group group = new Group();
    
    public Environment(double width, double height) {
        this.resize(width, height);
        this.drawBackgound();
        this.initGroup();
    }
    
    private void initGroup() {
        group.setLayoutX(100);
        group.setLayoutY(100);
        group.setEffect(new DropShadow(50, 10, 10, Color.BLACK));
        this.getChildren().add(group);
    }
    
    
    private void drawBackgound() {
        double w = this.getWidth();
        double h = this.getHeight();
        double space = 10;
        double widthLine = 0.5;
        for (int i = 0; i < w; i += space) {
            Line line = new Line(i, 0, i, h);
            line.setStrokeWidth(widthLine);
            this.getChildren().add(line);
        }
        
        for (int i = 0; i < h; i += space) {
            Line line = new Line(0, i, w, i);
            line.setStrokeWidth(widthLine);
            this.getChildren().add(line);
        }
    }

    public Group getGroup() {
        return group;
    }

    public void addShape(Node node) {
        group.getChildren().add(node);
    }
}
